package com.common.sub.util;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.filter.authc.UserFilter;

public class UserAuthenticationFilter  extends UserFilter{

	@Override
	protected boolean isAccessAllowed(ServletRequest arg0,ServletResponse arg1, Object arg2) {
		if (isLoginRequest(arg0, arg1)){
			return true;
		}else{
			
			 Subject subject = getSubject(arg0, arg1);
			 if(subject.getPrincipal() != null&&subject.isAuthenticated()){
				 return true;
			 }else{
				 return false;
			 }
		}
		
	}

//	@Override
//	protected boolean onAccessDenied(ServletRequest request,ServletResponse response) throws Exception {
//		 Subject subject = getSubject(request, response);
//		 
//		 System.out.println(subject);
//		 
//		return super.onAccessDenied(request, response);
//	}
	

}
